//
//  OMOrderUnfinishTableCell.m
//  OMENGO_NEW
//
//  Created by 梁尚嘉 on 2017/5/5.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMOrderTableCell.h"

@implementation OMOrderTableCell {
    UIButton *_rightButton;
    UIButton *_middleButton;
    NSArray <UIButton *>*_buttons;
}

- (void)configure
{
    [super configure];

    _rightButton = [self createButtonWithTitle:@"去支付" andIsFill:true];
    [self.bottomView addSubview:_rightButton];
    [_rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(SM_SIZE(-30)));
        make.top.equalTo(self.infoLabel.mas_bottom).offset(SM_SIZE(20));
        make.height.equalTo(@(SM_SIZE(60)));
        make.width.equalTo(@(SM_SIZE(150)));
    }];

    _middleButton = [self createButtonWithTitle:@"删除订单" andIsFill:false];
    [self.bottomView addSubview:_middleButton];
    [_middleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_rightButton.mas_left).offset(SM_SIZE(-20));
        make.centerY.equalTo(_rightButton);
        make.width.height.equalTo(_rightButton);
    }];

    _buttons = @[_rightButton,_middleButton];
}


- (void)configureCellWithObj:(OMOrder *)order
{
    [super configureCellWithObj:order];
    NSArray <OMOrderButtonTitle *>*buttonTitles = [OMOrderButtonAdapter buttonTitlesWithStatus:order.status showInList:true];
    _rightButton.hidden = true;
    _middleButton.hidden = true;
    NSUInteger index = 0;
    for (OMOrderButtonTitle *buttonTitle in buttonTitles) {
        [self configureButton:_buttons[index] withTitle:buttonTitle.desc andIsFill:buttonTitle.isFullFill];
        _buttons[index].hidden = false;
        index ++;
    }
    
}



@end
